import * as echarts from 'echarts'
import { ref } from 'vue'

export default function initChartPie(id) {
  const myChartPie = ref(null)

  /**
   * 渲染折线图
   */
  const rednerPie = ({ El }) => {
    myChartPie.value = echarts.init(El)
    const option = {
      title: {
        text: '项目管理',
        subtext: '人员配置',
        left: 'center'
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        orient: 'vertical',
        left: 'left'
      },
      series: [
        {
          name: '任务量',
          type: 'pie',
          radius: '50%',
          data: [
            { value: 1048, name: '张三' },
            { value: 735, name: '李四' },
            { value: 580, name: '王五' },
            { value: 484, name: '小明' },
            { value: 300, name: '小红' }
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    }
    option && myChartPie.value.setOption(option)
  }

  return {
    myChartPie,
    rednerPie
  }
}
